package com.example.gulimallproduct.utlis;

import com.example.gulimallproduct.entity.CategoryEntity;
import com.example.gulimallproduct.service.CategoryService;
import org.springframework.stereotype.Component;

import java.util.LinkedList;

/**
 * &#064;Description:设置三级分类全路径
 **/

public  class SetCatelogPathUtils {
    public static LinkedList<Long> getCatelogPath(CategoryEntity categoryEntity, CategoryService categoryService){
        LinkedList<Long> catelogPath = new LinkedList<>();
        //获取分类全路径
        for (int i = 0; i < 3; i++) {
            catelogPath.addFirst(categoryEntity.getCatId());
            categoryEntity = categoryService.getById(categoryEntity.getParentCid());
        }
        return catelogPath;
    }
}
